package com.tledu.studentmanager.controller;

import com.tledu.studentmanager.domain.Student;
import com.tledu.studentmanager.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/student2")
public class StudentController2 {

    @Autowired
    private IStudentService studentService;

    @GetMapping("")
    public String listPage() {
        return "student2/list";
    }

    @GetMapping("/list")
    @ResponseBody
    public List<Student> getStudentList(String name, String school) {
        return studentService.selectList(name, school);
    }

    @GetMapping("/delete")
    @ResponseBody
    public int delete(int id) {
        return studentService.delete(id);
    }
}
